﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hotnet.Entity;
using Hotnet.Dal.NSDalPicture;
using Hotnet.Entity.Enum;
using Hotnet.Entity.Search;

namespace Hotnet.Biz.NSBizPicture
{
	public class BizPictureList:BaseBiz<PictureList>
	{

		private static DalPictureList db = new DalPictureList();

		public BizPictureList() : base(db) { }

		public void Delete(int groupId, EnumPictureListType listType)
		{
			db.DeleteBy(x => x.ListType == (int)listType && x.GroupID == groupId);
		}

		public PictureList Get(int groupId, EnumPictureListType listType)
		{
			return db.GetBy(x => x.ListType == (int)listType && x.GroupID == groupId);
		}

		/// <summary>
		/// 查出图片组所属的列表
		/// </summary>
		/// <param name="groupId"></param>
		/// <returns></returns>
		public PictureList[] List(int groupId)
		{
			return db.ListBy(x => x.GroupID == groupId);
		}

		public ViewPictureList[] List(SearchPictureList condition, int pageNo, int pageSize, out int totalCount)
		{
			return db.List(condition,pageNo,pageSize,out totalCount);
		}

		/// <summary>
		/// 列出图片各列表
		/// </summary>
		/// <param name="listType"></param>
		/// <param name="count"></param>
		/// <returns></returns>
		public ViewPictureList[] List(EnumPictureListType listType, int count)
		{
			int totalCount=0;
			SearchPictureList condition = new SearchPictureList() { IsPublished=EnumPublishState.发布, OrderType=EnumOrder.添加时间, ListType=listType };
			return List(condition, 0, count, out totalCount); 
		}

		/// <summary>
		/// 列出图片各列表（分类）
		/// </summary>
		/// <param name="listType"></param>
		/// <param name="count"></param>
		/// <returns></returns>
		public ViewPictureList[] List(EnumPictureListType listType,int categoryID, int count)
		{
			int totalCount = 0;
			SearchPictureList condition = new SearchPictureList() { IsPublished = EnumPublishState.发布, OrderType = EnumOrder.添加时间, ListType = listType, PictureCategroyId=categoryID };
			return List(condition, 0, count, out totalCount);
		}



	}
}
